// import { Canceler } from 'axios';
import { pget, ppostJson } from '@/utils/req';
import { modalApi } from '@/utils/modalReq';

// 获取角色列表
export function getRoleList(query: any) {
  return pget(`${modalApi.system}/role/list`, query);
}
// 通过用户获取角色列表
export function getUserByRoleList(userId: any, query: any) {
  return pget(`${modalApi.system}/role/list/user/${userId}`, query);
}

// 新增角色
export function addRole(data: any) {
  return ppostJson(`${modalApi.system}/role/create`, data);
}

// 修改角色
export function editRole(roleId: string, data: any) {
  return ppostJson(`${modalApi.system}/role/update/${roleId}`, data);
}

// 删除角色
export function deleteRole(roleId: any) {
  return ppostJson(`${modalApi.system}/role/delete/${roleId}`);
}

// 查看角色
export function viewRole(roleId: string) {
  return pget(`${modalApi.system}/role/info/${roleId}`);
}

// 角色分配用户
export function roleShareUser(roleId: string, data: any) {
  return ppostJson(`${modalApi.system}/role/${roleId}/assign/users`, data);
}

// 角色取消绑定
export function roleUnbindUser(roleId: string, data: any) {
  return ppostJson(`${modalApi.system}/role/${roleId}/delete/users`, data);
}
// 角色-拷贝角色
export function roleCopy(data: any) {
  return ppostJson(`${modalApi.system}/role/copy`, data);
}
